﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace DeckOfCards.Domain
{
    public class Seme
    {

        [XmlAttribute("Name")]
        public string Nome { get; set; }
        [XmlAttribute("Colore")]
        public string Colore { get; set; }


        private Seme(string Nome)
        {
            this.Nome = Nome;
            this.Colore = Colore;
        }

        private static List<Seme> semi = new List<Seme>();

        

        internal static Seme GetSeme(string nome)
        {

            Seme returnedSeme;

            try{
                returnedSeme = semi.First(x => x.Nome == nome);
            }
            catch(InvalidOperationException)
            {
                returnedSeme = new Seme(nome);
                semi.Add(returnedSeme);
            }

            return returnedSeme;

        }

    }



}
